<template>
  <div style="width: 400px;height: 200px">
    <h3 class="login-title">欢迎登录</h3>
    <el-form-item label="账号">
      <input type="text" v-model="userObj.userName"/>
    </el-form-item>
    <el-form-item label="密码">
      <input type="password" v-model="userObj.pwd"/>
    </el-form-item>
    <el-form-item>
      <button type="primary" @click="login()">登录</button>
    </el-form-item>
  </div>
</template>

<script>
import axios from "axios"

export default {
  name: "login",
  data() {
    return {
      form: {},
      userObj: {},
      loginInfo: {}
    }
  },
  methods: {
    login() {
      console.log(this.userObj)
      axios.get("/project/user/login", {
        params: this.userObj

      }).then(resp => {
        this.loginInfo = resp.data;
        console.log(this.loginInfo)
        if (this.loginInfo === "ok") {
          alert("登录成功");


          this.$router.push("/index");
        } else if (this.loginInfo === "no") {
          alert("登录失败");
        }
      })
    }
  }

}
</script>

<style scoped>

</style>